package interfaze;

import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import logic.Mp3Player;
import logic.NoSaveException;
import logic.Utilities;

import constants.PercentNumber;
import constants.ResolutionOptions;

/**Brick Breaker Options Panel's class.
 * @author Team 1
 *
 */
@SuppressWarnings("serial")
public class BrickBreakerOptionsPanel extends JPanel implements ActionListener, ItemListener, ChangeListener, MouseListener {
	
	private SuperArcade2in1 window;												//The JFrame in which this panel is being added.
	private JLabel lResolution = new JLabel("Resolution:");						//The resolution's label. 
	private JLabel lFullScreen = new JLabel("Set Full Screen:");				//The fullscreen's label.
	private JLabel lDecoration = new JLabel("Set Decoration:");					//The decoration's label.
	private JLabel lSound = new JLabel("Enable Music:");						//The music's label.
	private JLabel lLivesNum = new JLabel("Lifes Number:");						//The lives' number.
	private JLabel lAmmoNum = new JLabel("Ammunition Number:");					//The ammo label.
	private JLabel lColumnNum = new JLabel("Column Number:");					//The column label.
	private JLabel lRowNum = new JLabel("Row Number:");							//The row label.
	private JLabel lBallSpeed = new JLabel("Ball's Speed:");					//The ball's speed label.
	private JLabel lBatSpeed = new JLabel("Bat's Speed:");						//The bat's speed label.
	private JLabel lBonusSpeed = new JLabel("Bonus' Speed");					//The bonus' speed label.
	private JLabel lBonusPercent = new JLabel("Bonus' Creation Percent:");		//The percent's label.
	private JSlider slLives = new JSlider();									//The lives' slider.
	private JLabel lCurrentLives = new JLabel();								//The current lives' label.
	private JSlider slAmmo = new JSlider();										//The ammo's slider.
	private JLabel lCurrentAmmo = new JLabel();									//The current ammo's label.
	private JSlider slRows = new JSlider();										//The rows' label.
	private JLabel lCurrentRows = new JLabel();									//The current rows' label.
	private JSlider slColumns = new JSlider();									//The columns' slider.
	private JLabel lCurrentColumns = new JLabel();								//The current column's label.
	private JSlider slBallSpeed = new JSlider();								//The ball's speed slider.
	private JLabel lCurrentBallSpeed = new JLabel();							//The current ball speed's label.
	private JSlider slBatSpeed = new JSlider();									//The bat speed's slider.
	private JLabel lCurrentBatSpeed = new JLabel();								//The current bat speed's label.
	private JSlider slBonusSpeed = new JSlider();								//The bonus speed's slider.
	private JLabel lcurrentBonusSpeed = new JLabel();							//The current bonus speed's label.
	private JSlider slPercent = new JSlider();									//The percent's slider.
	private JLabel lCurrentPercent = new JLabel();								//The current percent's label.
	private Font font;															//The font used by all the buttons and labels.
	private JButton bBack = new JButton("Back");								//The Back button.
	private JCheckBox cbFullScreen = new JCheckBox();							//Full Screen Check Box.
	@SuppressWarnings({ "unchecked", "rawtypes" })
	private JComboBox cbResolution = new JComboBox(ResolutionOptions.getValues());		//Resolution ComboBox.
	private JCheckBox cbDecoration = new JCheckBox();							//The Decoration Check Box.
	private JCheckBox cbSound = new JCheckBox();								//The Music Check Box.
	private JLabel background = new JLabel();									//The background of this JPanel.
	private String parent;	//The code-name of the JPanel that summoned this JPanel.
	
	/**BrickBreakerOptionsPanel's constructor.
	 * @param window : The JFrame in which this panel is being added.
	 * @param parent : The code-name of the JPanel that summoned this JPanel. ("MainMenu" or "PauseMenu")
	 */
	public BrickBreakerOptionsPanel(SuperArcade2in1 window, String parent) {
		this.window = window;
		this.parent = parent;
		
		//Sets the layout to null in order to work with absolute coordinates.
		this.setLayout(null);
		
		//Sets the font for all the text panels and the buttons.
		font = new Font("Helvetica", Font.PLAIN, Math.round(12 * window.xScale));
		
		//Sets all the components of the panel. Their boundaries, font and so on.
		lResolution.setFont(font);
		lResolution.setForeground(Color.WHITE);
		lResolution.setBounds(Math.round(75 * window.xScale), Math.round(350 * window.yScale),
				Math.round(75 * window.xScale), Math.round(25 * window.yScale));
		cbResolution.setFont(font);
		cbResolution.setBounds(Math.round(150 * window.xScale), Math.round(350 * window.yScale), 
				Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lFullScreen.setFont(font);
		lFullScreen.setForeground(Color.WHITE);
		lFullScreen.setBounds(Math.round(75 * window.xScale), Math.round(380 * window.yScale),
				Math.round(95 * window.xScale), Math.round(25 * window.yScale));
		
		cbFullScreen.setBounds(Math.round(165 * window.xScale), Math.round(380 * window.yScale),
				Math.round(32 * window.xScale), Math.round(25 * window.yScale));
		cbFullScreen.setOpaque(false);
		
		lDecoration.setFont(font);
		lDecoration.setForeground(Color.WHITE);
		lDecoration.setBounds(Math.round(77 * window.xScale), Math.round(410 * window.yScale),
				Math.round(92 * window.xScale), Math.round(25 * window.yScale));
		
		cbDecoration.setBounds(Math.round(165 * window.xScale), Math.round(410 * window.yScale),
				Math.round(32 * window.xScale), Math.round(25 * window.yScale));
		cbDecoration.setOpaque(false);
		
		//If music is being played set the check box selected.
		if(window.player != null) {
			cbSound.setSelected(true);
		}
		
		//If the JFrame is undecorated set the check box selected.
		if(!window.isUndecorated()) {
			cbDecoration.setSelected(true);
		}
		//If the JFrame is on full screen.
		if(window.isOnFullScreen) {
			//Sets invisible the combo box and set the decoration check box disabled.
			cbDecoration.setEnabled(false);
			lResolution.setVisible(false);
			cbResolution.setVisible(false);
			cbFullScreen.setSelected(true);
		}
		
		//Select the combo box with JFrames actual resolution.
		cbResolution.setSelectedItem(logic.Utilities.resolutionToStringParser(window.width, window.height));
		
		lSound.setFont(font);
		lSound.setForeground(Color.WHITE);
		lSound.setBounds(Math.round(77 * window.xScale), Math.round(440 * window.yScale),
				Math.round(92 * window.xScale), Math.round(25 * window.yScale));
		
		cbSound.setBounds(Math.round(165 * window.xScale), Math.round(440 * window.yScale),
				Math.round(32 * window.xScale), Math.round(25 * window.yScale));
		cbSound.setOpaque(false);
		
		lLivesNum.setFont(font);
		lLivesNum.setForeground(Color.WHITE);
		lLivesNum.setBounds(Math.round(300 * window.xScale), Math.round(350 * window.yScale), 
				Math.round(85 * window.xScale), Math.round(25 * window.yScale));
		
		slLives.setOpaque(false);
		slLives.setMinimum(1);
		slLives.setMaximum(10);
		slLives.setBounds(Math.round(385 * window.xScale), Math.round(350 * window.yScale), 
				Math.round(136 * window.xScale), Math.round(25 * window.yScale));
	
		lCurrentLives.setFont(font);
		lCurrentLives.setForeground(Color.WHITE);
		lCurrentLives.setBounds(Math.round(521 * window.xScale), Math.round(350 * window.yScale), 
				Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lAmmoNum.setFont(font);
		lAmmoNum.setForeground(Color.WHITE);
		lAmmoNum.setBounds(Math.round(300 * window.xScale), Math.round(380 * window.yScale), 
				Math.round(125 * window.xScale), Math.round(25 * window.yScale));
		
		slAmmo.setOpaque(false);
		slAmmo.setMinimum(0);
		slAmmo.setMaximum(99);
		slAmmo.setBounds(Math.round(425 * window.xScale), Math.round(380 * window.yScale), 
				Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lCurrentAmmo.setFont(font);
		lCurrentAmmo.setForeground(Color.WHITE);
		lCurrentAmmo.setBounds(Math.round(561 * window.xScale), Math.round(380 * window.yScale), 
				Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lRowNum.setFont(font);
		lRowNum.setForeground(Color.WHITE);
		lRowNum.setBounds(Math.round(300 * window.xScale), Math.round(410 * window.yScale), 
				Math.round(100 * window.xScale), Math.round(25 * window.yScale));
		
		slRows.setOpaque(false);
		slRows.setMinimum(1);
		slRows.setMaximum(15);
		slRows.setBounds(Math.round(400 * window.xScale), Math.round(410 * window.yScale), 
				Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lCurrentRows.setFont(font);
		lCurrentRows.setForeground(Color.WHITE);
		lCurrentRows.setBounds(Math.round(536 * window.xScale), Math.round(410 * window.yScale), 
		Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lColumnNum.setFont(font);
		lColumnNum.setForeground(Color.WHITE);
		lColumnNum.setBounds(Math.round(300 * window.xScale), Math.round(440 * window.yScale), 
				Math.round(100 * window.xScale), Math.round(25 * window.yScale));
		
		slColumns.setOpaque(false);
		slColumns.setMinimum(1);
		slColumns.setMaximum(20);
		slColumns.setBounds(Math.round(400 * window.xScale), Math.round(440 * window.yScale), 
				Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lCurrentColumns.setFont(font);
		lCurrentColumns.setForeground(Color.WHITE);
		lCurrentColumns.setBounds(Math.round(536 * window.xScale), Math.round(440 * window.yScale), 
		Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lBallSpeed.setFont(font);
		lBallSpeed.setForeground(Color.WHITE);
		lBallSpeed.setBounds(Math.round(300 * window.xScale), Math.round(470 * window.yScale), 
				Math.round(100 * window.xScale), Math.round(25 * window.yScale));
		
		slBallSpeed.setOpaque(false);
		slBallSpeed.setMinimum(1);
		slBallSpeed.setMaximum(6);
		slBallSpeed.setBounds(Math.round(400 * window.xScale), Math.round(470 * window.yScale), 
				Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lCurrentBallSpeed.setFont(font);
		lCurrentBallSpeed.setForeground(Color.WHITE);
		lCurrentBallSpeed.setBounds(Math.round(536 * window.xScale), Math.round(470 * window.yScale), 
		Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lBatSpeed.setFont(font);
		lBatSpeed.setForeground(Color.WHITE);
		lBatSpeed.setBounds(Math.round(300 * window.xScale), Math.round(500 * window.yScale), 
				Math.round(100 * window.xScale), Math.round(25 * window.yScale));
		
		slBatSpeed.setOpaque(false);
		slBatSpeed.setMinimum(1);
		slBatSpeed.setMaximum(10);
		slBatSpeed.setBounds(Math.round(400 * window.xScale), Math.round(500 * window.yScale), 
				Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lCurrentBatSpeed.setFont(font);
		lCurrentBatSpeed.setForeground(Color.WHITE);
		lCurrentBatSpeed.setBounds(Math.round(536 * window.xScale), Math.round(500 * window.yScale), 
		Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lBonusSpeed.setFont(font);
		lBonusSpeed.setForeground(Color.WHITE);
		lBonusSpeed.setBounds(Math.round(300 * window.xScale), Math.round(530 * window.yScale), 
				Math.round(100 * window.xScale), Math.round(25 * window.yScale));
		
		slBonusSpeed.setOpaque(false);
		slBonusSpeed.setMinimum(1);
		slBonusSpeed.setMaximum(6);
		slBonusSpeed.setBounds(Math.round(400 * window.xScale), Math.round(530 * window.yScale), 
				Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lcurrentBonusSpeed.setFont(font);
		lcurrentBonusSpeed.setForeground(Color.WHITE);
		lcurrentBonusSpeed.setBounds(Math.round(536 * window.xScale), Math.round(530 * window.yScale), 
		Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lBonusPercent.setFont(font);
		lBonusPercent.setForeground(Color.WHITE);
		lBonusPercent.setBounds(Math.round(300 * window.xScale), Math.round(560 * window.yScale), 
				Math.round(150 * window.xScale), Math.round(25 * window.yScale));
		
		slPercent.setOpaque(false);
		slPercent.setMinimum(0);
		slPercent.setMaximum(3);
		slPercent.setBounds(Math.round(450 * window.xScale), Math.round(560 * window.yScale), 
				Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		lCurrentPercent.setFont(font);
		lCurrentPercent.setForeground(Color.WHITE);
		lCurrentPercent.setBounds(Math.round(586 * window.xScale), Math.round(560 * window.yScale), 
				Math.round(136 * window.xScale), Math.round(25 * window.yScale));
		
		//Load the current values for the sliders and the labels from the configuration saves.
		PercentNumber percent;
		try {
			ArrayList<Object> config = logic.BrickBreakerConfig.load(window.userName);
			if((boolean) config.get(0)) {
				cbSound.setSelected(true);
			}
			slLives.setValue((Integer)config.get(1));
			lCurrentLives.setText("" + (Integer)config.get(1));
			slAmmo.setValue((Integer)config.get(2));
			lCurrentAmmo.setText("" + (Integer)config.get(2));
			slRows.setValue((Integer)config.get(3));
			lCurrentRows.setText("" + (Integer)config.get(3));
			slColumns.setValue((Integer)config.get(4));
			lCurrentColumns.setText("" + (Integer)config.get(4));
			slBallSpeed.setValue((Integer)config.get(5));
			lCurrentBallSpeed.setText("" + (Integer)config.get(5) * 2);
			slBatSpeed.setValue((Integer)config.get(6));
			lCurrentBatSpeed.setText("" + (Integer)config.get(6) * 2);
			slBonusSpeed.setValue((Integer)config.get(7));
			lcurrentBonusSpeed.setText("" + (Integer)config.get(7) * 2);
			percent = (PercentNumber) config.get(8);
		} catch (NoSaveException e) {
			//If there's not save data sets default values.
			slLives.setValue(3);
			lCurrentLives.setText("" + 3);
			slAmmo.setValue(0);
			lCurrentAmmo.setText("" + 0);
			slRows.setValue(5);
			lCurrentRows.setText("" + 5);
			slColumns.setValue(20);
			lCurrentColumns.setText("" + 20);
			slBallSpeed.setValue(3);
			lCurrentBallSpeed.setText("" + 6);
			slBatSpeed.setValue(4);
			lCurrentBatSpeed.setText("" + 8);
			slBonusSpeed.setValue(3);
			lcurrentBonusSpeed.setText("" + 6);
			percent = PercentNumber.TWENTY_FIVE;
		}
		
		//Displays the percent value to string and sets the slider.
		switch(percent) {
		case ZERO:
			slPercent.setValue(0);
			lCurrentPercent.setText("0%");
			break;
		case TWENTY_FIVE:
			slPercent.setValue(1);
			lCurrentPercent.setText("25%");
			break;
		case FIFTY:
			slPercent.setValue(2);
			lCurrentPercent.setText("50%");
			break;
		case HUNDRED:
			slPercent.setValue(3);
			lCurrentPercent.setText("100%");
			break;
		}
		
		//If the pause panel summoned this panel disables all the sliders related to the game configuration.
		if(parent.equals("PauseMenu")) {
			slLives.setEnabled(false);
			slAmmo.setEnabled(false);
			slRows.setEnabled(false);
			slColumns.setEnabled(false);
			slBallSpeed.setEnabled(false);
			slBatSpeed.setEnabled(false);
			slBonusSpeed.setEnabled(false);
			slPercent.setEnabled(false);
		}
		bBack.setFont(font);
		bBack.setBounds(Math.round(75 * window.xScale), Math.round(590 * window.yScale), Math.round(100 * window.xScale),
				Math.round(25 * window.yScale));
		
		//Sets background of the panel.
		Image image = Utilities.loadImage("res/background.png");
		if(window.xScale != 1 || window.yScale != 1) {
			image = Utilities.resizeImage(window.xScale, window.yScale, "res/background.png");
		}
		background.setIcon(new ImageIcon(image));
		background.setBounds(0, 0, image.getWidth(null), image.getHeight(null));
		
		//Adds the components to the panel..
		this.add(lResolution);
		this.add(cbResolution);
		this.add(lFullScreen);
		this.add(cbFullScreen);
		this.add(lLivesNum);
		this.add(slLives);
		this.add(lCurrentLives);
		this.add(lDecoration);
		this.add(cbDecoration);
		this.add(lSound);
		this.add(cbSound);
		this.add(lAmmoNum);
		this.add(slAmmo);
		this.add(lCurrentAmmo);
		this.add(lRowNum);
		this.add(slRows);
		this.add(lCurrentRows);
		this.add(lColumnNum);
		this.add(slColumns);
		this.add(lCurrentColumns);
		this.add(lBallSpeed);
		this.add(slBallSpeed);
		this.add(lCurrentBallSpeed);
		this.add(lBatSpeed);
		this.add(slBatSpeed);
		this.add(lCurrentBatSpeed);
		this.add(lBonusSpeed);
		this.add(slBonusSpeed);
		this.add(lcurrentBonusSpeed);
		this.add(lBonusPercent);
		this.add(slPercent);
		this.add(lCurrentPercent);
		this.add(bBack);
		this.add(background);
		
		//Adds the listeners to the components.
		cbResolution.addActionListener(this);
		cbDecoration.addItemListener(this);
		cbFullScreen.addItemListener(this);
		cbSound.addItemListener(this);
		slLives.addChangeListener(this);
		slAmmo.addChangeListener(this);
		slRows.addChangeListener(this);
		slColumns.addChangeListener(this);
		slBallSpeed.addChangeListener(this);
		slBatSpeed.addChangeListener(this);
		slBonusSpeed.addChangeListener(this);
		slPercent.addChangeListener(this);
		bBack.addActionListener(this);
		bBack.addMouseListener(this);
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource().equals(bBack)) {
			//Saves all the components values to the BBCONFIG table.
			Boolean bool = new Boolean(cbSound.isSelected());
			Integer lifesNumber = new Integer(slLives.getValue());
			Integer ammoNumber = new Integer(slAmmo.getValue());
			Integer rowNumber = new Integer(slRows.getValue());
			Integer columnNumber = new Integer(slColumns.getValue());
			Integer ballSpeed = new Integer(slBallSpeed.getValue());
			Integer batSpeed = new Integer(slBatSpeed.getValue());
			PercentNumber percent = null;
			switch(slPercent.getValue()) {
			case 0:
				percent = PercentNumber.ZERO;
				break;
			case 1:
				percent = PercentNumber.TWENTY_FIVE;
				break;
			case 2:
				percent = PercentNumber.FIFTY;
				break;
			case 3:
				percent = PercentNumber.HUNDRED;
				break;
			}
			Integer bonusSpeed = new Integer(slBonusSpeed.getValue());
			logic.BrickBreakerConfig.write(window.userName, bool, lifesNumber, ammoNumber, 
					rowNumber, columnNumber, ballSpeed, batSpeed, bonusSpeed, percent);
			
			//Saves all the UI configuration into UIConfig table.
			Boolean bool2 = new Boolean(cbFullScreen.isSelected());
			String resolution = cbResolution.getSelectedItem().toString();
			Boolean bool3 = new Boolean(cbDecoration.isSelected());
			if(window.isOnFullScreen) {
				bool3 = new Boolean(false);
				resolution = "1280x720";
			}
			logic.UIConfig.write(window.userName, bool2, resolution, bool3);
			
			if(parent.equals("MainMenu")) {
				//Redirects to the main menu.
				window.add(new BrickBreakerMainMenuPanel(window));
			} else if(parent.equals("PauseMenu")) {
				//Redirects to the pause menu.
				window.add(new BrickBreakerPausePanel(window));
			}
			this.setVisible(false);
			window.remove(this);
		} else if(e.getSource().equals(cbResolution)) {
			//Changes the resolution of the JFrame and the panel.
			Utilities.stringToResolutionParser((String) cbResolution.getSelectedItem(), window);
			if(window.width >= (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth())) {
				window.setSize(window.width, window.height);
				window.setLocation(0, 0);
			} else {
				window.setBounds((window.FULLSCREEN_WIDTH / 2) - (window.width / 2), 
						(window.FULLSCREEN_HEIGHT / 2) - (window.height / 2), window.width, window.height);
			}
			BrickBreakerOptionsPanel panel = new BrickBreakerOptionsPanel(window, parent);
			window.add(panel);
			panel.requestFocus();
			this.setVisible(false);
			window.remove(this);
		}
	}

	@Override
	public void itemStateChanged(ItemEvent e) {
		if(e.getSource() == cbDecoration) {
			window.dispose();
			//Sets the decoration of the JFrame.
			if(cbDecoration.isSelected()) {
				window.setUndecorated(false);
			} else {
				window.setUndecorated(true);
			}
			window.setVisible(true);
		} else if(e.getSource().equals(cbFullScreen)) {
			if(cbFullScreen.isSelected()) {
				//Changes the JFrame to full screen.
				Utilities.windowToFullScreen(window);
				BrickBreakerOptionsPanel panel = new BrickBreakerOptionsPanel(window, parent);
				window.add(panel);
				panel.requestFocus();
				this.setVisible(false);
				window.remove(this);
			} else {
				//Changes the JFrame from full screen to default resolution.
				Utilities.stringToResolutionParser("1280x720", window);
				if(window.width >= (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth())) {
					window.setSize(window.width, window.height);
					window.setLocation(0, 0);
				} else {
					window.setBounds((window.FULLSCREEN_WIDTH / 2) - (window.width / 2), 
							(window.FULLSCREEN_HEIGHT / 2) - (window.height / 2), window.width, window.height);
				}
				window.add(new BrickBreakerOptionsPanel(window, parent));
				this.setVisible(false);
				window.remove(this);
			}
		} else if(e.getSource().equals(cbSound)) {
			if(cbSound.isSelected()) {
				//If the music is stopped
				if(window.player == null) {
					//plays the sound.
					window.player = new Mp3Player("res/Nepgear.mp3");
					window.player.start();
				}
			} else {
				//If the music is being played.
				if(window.player != null) {
					//Stops the music.
					window.player.stopPlayer();
					window.player = null;
				}
			}
		}
	}

	@Override
	public void stateChanged(ChangeEvent e) {
		//Updates the current label's values.
				if(e.getSource() == slLives) {
					lCurrentLives.setText("" + slLives.getValue());
				} else if(e.getSource() == slAmmo) {
					lCurrentAmmo.setText("" + slAmmo.getValue());
				} else if(e.getSource() == slRows) {
					lCurrentRows.setText("" + slRows.getValue());
				} else if(e.getSource() == slColumns) {
					lCurrentColumns.setText("" + slColumns.getValue());
				} else if(e.getSource() == slBallSpeed) {
					lCurrentBallSpeed.setText("" + slBallSpeed.getValue() * 2);
				} else if(e.getSource() == slBatSpeed) {
					lCurrentBatSpeed.setText("" + slBatSpeed.getValue() * 2);
				} else if(e.getSource() == slBonusSpeed) {
					lcurrentBonusSpeed.setText("" + slBonusSpeed.getValue() * 2);
				}else if(e.getSource() == slPercent) {
					switch(slPercent.getValue()) {
					case 0:	
						lCurrentPercent.setText("0%");
						break;
					case 1:
						lCurrentPercent.setText("25%");
						break;
					case 2:
						lCurrentPercent.setText("50%");
						break;
					case 3:
						lCurrentPercent.setText("100%");
						break;
					}
				}
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		//Increases the buttons size when the mouse enters them.
		if(e.getSource().equals(bBack)) {
			Utilities.buttonEffect(bBack, 5, window.xScale, window.yScale);
		}
	}

	@Override
	public void mouseExited(MouseEvent e) {
		//Decreases the buttons size when the mouse enters them.
		if(e.getSource().equals(bBack)) {
			Utilities.buttonEffect(bBack, -5, window.xScale, window.yScale);
		}
	}

	@Override
	public void mousePressed(MouseEvent e) {
		//Do nothing here.
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		//Do nothing here.
	}
	@Override
	public void mouseClicked(MouseEvent e) {
		//Do nothing here.
	}

}